package swa2012.telco.provider;

import java.util.Collection;

import javax.jws.WebService;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

import swa2012.telco.broker.Client;
import swa2012.telco.broker.Message;
import swa2012.telco.broker.Provider;
import swa2012.telco.broker.ReceiveMessageStatus;

@WebService(endpointInterface = "swa2012.telco.provider.IBrokerCallback")
public class BrokerCallbackImpl implements IBrokerCallback {
	
//	JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
	private ClientContainer clientContainer = ClientContainer.getInstance();

	public ReceiveMessageStatus receiveMessage(Message msg) {
		// TODO Auto-generated method stub
		return null;
	}

	public Collection<Client> listClients() {
//		factory.setServiceClass(IProvider.class);
//		factory.setAddress("http://student.swa.univie.ac.at:8013/telco/Provider");
//		factory.getInInterceptors().add(new LoggingInInterceptor());
//		factory.getOutInterceptors().add(new LoggingOutInterceptor());
//		IProvider provider = (IProvider) factory.create();
//		Collection<Client> clientList = provider.listClient();
		return clientContainer.getClientList();
	}

	public Boolean ping() {
		return true;
	}

}
